//
//  Sound.m
//  TowerDefence
//
//  Created by  on 5/21/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "Sound.h"
#import "SimpleAudioEngine.h"

@implementation Sound

static Sound* _instance;

-(id)init {
    self = [super init];
    
    return self;
}

+(Sound *)getInstance {
    @synchronized(self) {
        if (_instance == nil)
            _instance = [[Sound alloc] init];
    }
    return _instance;
}

-(void)preloadSoundEffect:(NSString *)_fileName {
    [[SimpleAudioEngine sharedEngine] preloadEffect:_fileName];
}

-(void)unloadSoundEffect:(NSString *)_fileName {
    [[SimpleAudioEngine sharedEngine]unloadEffect:_fileName];
}

-(void)setEffectVolume:(float)_value {
    [[SimpleAudioEngine sharedEngine] setEffectsVolume:_value];
}

-(void)playBackgroundMusic:(NSString *)_fileName isLoop:(BOOL)_isLoop {
    [[SimpleAudioEngine sharedEngine] playBackgroundMusic:_fileName loop:_isLoop];
}

-(void)playEffect:(NSString *)_fileName {
    [[SimpleAudioEngine sharedEngine] playEffect:_fileName];
}

-(void)stopSoundEffect {
    [[SimpleAudioEngine sharedEngine] stopEffect:nil];
}

-(void) setMute:(bool)status{
    [[SimpleAudioEngine sharedEngine] setMute:status];
}

-(void)stopBackgroundMusic {
    [[SimpleAudioEngine sharedEngine] stopBackgroundMusic];
}

-(void)setBackgroundMusicVolume:(float)_value {
    [[SimpleAudioEngine sharedEngine] setBackgroundMusicVolume:_value];
}

@end
